<template>
  <div class="container">
    <div class="mask1"
         v-if="isHidden">
      <div class="pswbox">
        <p class="psw_title">验证登录密码</p>
        <p class="psw_tip">如忘记登录密码，请前往【我的】-【设置】 中心进行修改</p>
        <input type="password"
               class="pswInput"
               v-model="psw_value">
        <p class="pwd_choose_btn">
          <span @click="closeMask"
                class="cannle">取消</span>
          <span @click="testPsw"
                class="comfire">确认</span>
        </p>
      </div>
    </div>
    <ul class="card-list"
        v-if="is_show">
      <li class="list-item clearfix"
          :style="{backgroundImage:'url('+imgUrl+list_data.bgImg+')'}">
        <div class="header clearfix">
          <div class="logo">
            <img :src="imgUrl+list_data.logo"
                 alt=""
                 class="logo-img">
          </div>
          <div class="info">
            <div class="bank-name">
              {{list_data.name}}
            </div>
            <div class="card-type">
              {{list_data.type}}
            </div>
          </div>
        </div>
        <div class="card-num">
          ****&nbsp;&nbsp;&nbsp;&nbsp;****&nbsp;&nbsp;&nbsp;&nbsp;****&nbsp;&nbsp;&nbsp;&nbsp;{{list_data.num}}
        </div>
      </li>
    </ul>
    <div class="add-btn"
         @click="select">
      解除绑定
    </div>
  </div>
</template>


<script>
import common from "@/assets/js/mmk_common.js";
export default {
  data () {
    return {
      list_data: "",
      imgUrl: common.image_response,
      isHidden: false,
      psw_value: '',
      is_show: true
    };
  },
  methods: {
    select () {
      this.isHidden = true;
    },
    testPsw () {
      common.mmk_Loading(0)
      common.fly_post("api/v4_2/user_pass/verify", {
        password: this.psw_value
      }, result => {
        common.mmk_Loading(1);
        let res = result.data;
        if (res.status_code == 0) {
          if (res.data.status == true) {
            this.unbind();
          } else {
            common.mmk_Loading(2, "密码错误")
          }
        } else {
          common.mmk_Loading(2, res.message)
        }
      })
    },
    unbind () {
      common.fly_post("api/v4_2/user_cards/del", {
        id: this.list_data.id
      }, result => {
        let res = result.data;
        if (res.status_code == 0) {
          common.mmk_Loading(2, "解绑成功")
          this.isHidden = false;
          this.is_show = false;
          setTimeout(() => {
            wx.navigateBack({
              delta: 1 //返回的页面数，如果 delta 大于现有页面数，则返回到首页,
            });
          }, 1500)
        } else {
          common.mmk_Loading(2, res.message)
        }
      })
    },
    closeMask () {
      this.isHidden = false;
      this.psw_value = ''
    }

  },

  onLoad (options) {
    wx.setNavigationBarTitle({
      title: "银行卡详情"
    });
    this.psw_value = '';
    if (options) {
      this.list_data = options;
      this.is_show = true
    }
    wx.setNavigationBarColor({
      frontColor: "#000000", //前景颜色值，包括按钮、标题、状态栏的颜色，仅支持 #ffffff 和 #000000,
      backgroundColor: "#fff", //背景颜色值，有效值为十六进制颜色,
      success: res => { }
    });
  }
};
</script>

<style lang="less" scoped>
.container {
  width: 100%;
  height: 100%;
  padding: 10px 15px 0;
  background-color: #f3f4f6;
  box-sizing: border-box;
  position: relative;
  .mask1 {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9999;
    .pswbox {
      position: absolute;
      width: 305px;
      height: 202px;
      background: #fff;
      border-radius: 8px;
      z-index: 10000;
      color: #444;
      top: 28%;
      left: 9%;
      .pswInput {
        width: 86%;
        height: 40px;
        box-sizing: border-box;
        border-radius: 8px;
        border: 1px solid #ccc;
        margin: 0 auto;
        margin-top: 34px;
        padding: 0 50px;
        text-align: center;
        font-size: 17px;
      }
      .psw_tip {
        width: 86%;
        height: 17px;
        font-size: 12px;
        color: #888;
        margin: 10px auto 0;
        position: relative;
        text-align: center;
        color: #333333;
      }
      .psw_title {
        margin-top: 13px;
        font-size: 17px;
        text-align: center;
        font-weight: 900;
      }
      .pwd_choose_btn {
        width: 100%;
        border-top: solid 1px #dddddd;
        display: flex;
        position: absolute;
        bottom: 0;
        left: 0;
        .cannle {
          display: block;
          flex: 1;
          text-align: center;
          font-size: 18px;
          padding: 10px;
          color: #666666;
        }
        .comfire {
          display: block;
          flex: 1;
          text-align: center;
          font-size: 18px;
          padding: 10px;
          color: #666666;
          border-left: solid 1px #dddddd;
          color: #f64665;
        }
      }
    }
  }

  .card-list {
    margin: 0 auto;
    padding-bottom: 60px;
    .list-item {
      width: 345px;
      height: 135px;
      border-radius: 16px;
      background-size: cover;
      position: relative;
      margin-bottom: 15px;
      .header {
        position: absolute;
        left: 26px;
        top: 20px;
        .logo {
          float: left;
          width: 36px;
          height: 36px;
          border-radius: 50%;
          .logo-img {
            width: 100%;
            height: 100%;
            border-radius: 50%;
          }
        }
        .info {
          float: left;
          margin-left: 16px;
          .bank-name {
            font-size: 17px;
            font-family: "PingFangSC-Regular";
            font-weight: 400;
            color: rgba(255, 255, 255, 1);
          }
          .card-type {
            font-size: 12px;
            font-family: "PingFangSC-Regular";
            font-weight: 400;
            color: rgba(255, 255, 255, 1);
          }
        }
      }
      .card-num {
        margin-top: 80px;
        font-size: 17px;
        font-family: "PingFangSC-Regular";
        font-weight: 400;
        color: rgba(255, 255, 255, 1);
        text-align: center;
      }
    }
  }
  .add-btn {
    width: 100%;
    height: 50px;
    box-sizing: border-box;
    line-height: 50px;
    text-align: center;
    background: #fff;
    color: rgba(51, 51, 51, 1);
    position: fixed;
    bottom: 0px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 17px;
    font-family: "Medium";
    font-weight: 500;
  }
  .empty {
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    .nothing {
      width: 122px;
      display: block;
      margin-bottom: 10px;
    }
    .msg {
      font-size: 14px;
      font-family: "PingFangSC-Regular";
      font-weight: 400;
      color: rgba(255, 255, 255, 1);
    }
  }
}
</style>

